#ifndef COMPONENTMANAGER_H
#define COMPONENTMANAGER_H

#include "IVisualisation.h"
#include "IAudio.h"
#include "IUserInterface.h"
#include "IWorldModel.h"
#include "ILogger.h"
#include "ISceneManager.h"
#include "IProjectileManager.h"
#include "IProfiler.h"
#include "IExplosionManager.h"
#include "IPhysics.h"

//!Singleton Component Manager. It initialises, stores and handles every component of the game.
class CComponentManager
{
private:
	//!Singleton variable
	static CComponentManager* m_instance;

	//!Visualisation pointer
	IVisualisation* m_visualisationComponent;

	//!Audio pointer
	IAudio* m_audioComponent;

	//!UI pointer.
	IUserInterface* m_uiComponent;

	//!World model pointer
	IWorldModel* m_worldModel;

	//!Logger console pointer
	ILogger* m_loggerConsole;

	//!Logger debug pointer
	ILogger* m_loggerDebug;

	//!Logger message box pointer
	ILogger* m_loggerMsgBox;

	//Scene manager pointer
	ISceneManager* m_sceneManager;

	//!Projectile manager pointer
	IProjectileManager* m_projectileManager;

	//!Profiler pointer
	IProfiler* m_profiler;

	//!Explosion manager pointer
	IExplosionManager* m_explosionManager;

	//Physics engine
	IPhysics* m_physicsEngine;


protected:
	//!Constructor
	CComponentManager();

	//!Destructor
	~CComponentManager();

public:
	//!Get the instance of the component manager.
	static CComponentManager& getInstance(void);

	//!Close the component manager.
	void close(void);

	//!Initialise the Visualisation component
	/*!
	\param visualisationName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initVisualisationComponent(const string& visualisationName);

	//!Initialise the Audio component
	/*!
	\param audioName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initAudioComponent(const string& audioName);

	//!Initialise the User Interface component
	/*!
	\param uiName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initUIComponent(const string& uiName);

	//!Initialise the World Model component
	/*!
	\param worldName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initWorldModelComponent(const string& worldName);

	//!Initialise the Logger component
	/*!
	\param loggerName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initLogger(const string& loggerName);

	//!Initialise the Scene Manager component
	/*!
	\param sceneName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initSceneManager(const string& sceneName);

	//!Initialise the Projectile Manager component
	/*!
	\param managerName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initProjectileManager(const string& managerName);

	//!Initialise the Profiler component
	/*!
	\param profilerName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initProfiler(const string& profilerName);

	//!Initialise the Explosion Manager component
	/*!
	\param managerName The name of the component
	\return True if the component is created. False if it failed.
	*/
	bool initExplosionManager(const string& managerName);

	bool initPhysicsEngine();
	//!Get the Visualisation component
	/*!
	\return A reference to the Visualisation component.
	*/
	IVisualisation& VISU(void);

	//!Get the Audio component
	/*!
	\return A reference to the Audio component.
	*/
	IAudio& AUDIO(void);

	//!Get the User Interface component
	/*!
	\return A reference to the User Interface component.
	*/
	IUserInterface& UI(void);

	//!Get the World Model component
	/*!
	\return A reference to the World Model component.
	*/
	IWorldModel& WORLD(void);

	//!Get the Console Logger component
	/*!
	\return A reference to the Console Logger component.
	*/
	ILogger& LOGCONSOLE(void);

	//!Get the Scene Manager component
	/*!
	\return A reference to the Scene Manager component.
	*/
	ISceneManager& SCENE(void);

	//!Get the Projectile Manager component
	/*!
	\return A reference to the Projecitle Manager component.
	*/
	IProjectileManager& PROJECTILE(void);

	//!Get the Profiler component
	/*!
	\return A reference to the Profiler component.
	*/
	IProfiler& PROFILER(void);

	//!Get the Explosion Manager component
	/*!
	\return A reference to the Explosion Manager component.
	*/
	IExplosionManager& EXPLOSION(void);

	IPhysics& PHYSICS(void);




	//!Get the Debug Logger component
	/*!
	\return A reference to the Debug Logger component.
	*/
	ILogger& LOGDEBUG(void);

	//!Get the Message Box Logger component
	/*!
	\return A reference to the Message Box Logger component.
	*/
	ILogger& LOGMSGBOX(void);

};

#define CM CComponentManager::getInstance()

#endif

